
/* This class stores global variables and parameters used in the experiments.
 * It also stores methods that are used to keep track of statistics in a synchronized fashion.
 */
public class Global {
	
	public static String ip = "127.0.0.1";
	public static int port = 20000;
	
	public static int numMachines = 4;
	public static int k = 2; // number of machines each is checking up on
	public static int size = 100; //queue size
	public static int T = 2250; //ms, time within in which we should see another ping
	public static int MAX = 10; //s, max time for completeness
	public static int offset = 250; //ms, extra time to account for pings due to latency
	public static int failure = (MAX)/2 * 1000;
	public static int roundTrip = 250; //ms, time between pings once T is over
	public static int grace = 30; //s, grace period to get all machines up and running
	public static int numMinutes = 10; //number of minutes of simulation
	
	public static int simLength = (numMinutes*60 + grace)*1000; // simulation legnth
	
	public static int numMessages = 0; //total number of messages sent in sim
	public static int numFailures = 0; //total number of failures detected

	public static boolean starter = false; //variable to determine who the starter of the algo is,
											//need a starter to ensure some level of synchronization when
											//running on multiple machines
	public static boolean demo = true; //variable to determine if we are running the Main code or FailureDetector
										//if FailureDetector we want to wait for the starter to initiate the other
										//nodes
	
	public static synchronized void update() { //way to synchronize adding up the number of messages
		numMessages++;						//used with Main only
	}
	
	public static synchronized void addFailure() { //way to synchronize adding up the number of failures
		numFailures++; 						//used with Main only
	}
	
	public static synchronized int getPort() {
		return port++;
	}
}
